<%@ page import="com.informet.ipd.modelo.dao.APermanenteDao" %>
<%@ page import="com.informet.ipd.modelo.vo.APermanenteVO" %>
<%@ page import="com.informet.ipd.struts.form.APermanenteForm" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.swing.JOptionPane"%>
<%@ page language="java"  pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %>
<%@ taglib uri="/tags/c" prefix="c"%>

<%

            StringBuffer cadenaSalida = new StringBuffer();
            List lista = null;


            APermanenteDao supportFacade = new APermanenteDao();
            APermanenteForm form1 = new APermanenteForm();
            APermanenteVO aPer = null;
             APermanenteVO aPerM = null;
            try {
                String desc = request.getParameter("desc");

                int codOEsp = Integer.parseInt(request.getParameter("codOEsp"));
                int cod = Integer.parseInt(request.getParameter("codigo"));
                int tipo = Integer.parseInt(request.getParameter("tipo"));
                //int depen=Integer.parseInt(session.getAttribute("dependencia").toString());
                int respon= Integer.parseInt(request.getParameter("respon"))  ;
                int idActPer= Integer.parseInt(request.getParameter("idActPer"))  ;

                //int numdependencia=1;
                aPer = new APermanenteVO(cod,desc,codOEsp,0,respon,idActPer);

                /*
                cs.setInt(1, tipo);
            cs.setInt(2, bean.getNUM_CODACTPER_PK());
            cs.setString(3, bean.getTX_DESCACTPER());
            cs.setInt(4, bean.getNUM_CODOBJESP_PK());
            cs.setDouble(5, bean.getNUM_PRESUACTPER());
            cs.setInt(6, bean.getNUM_CODDEPEN_PK());
                */

                supportFacade.spMan(tipo, aPer);
                //int max=supportFacade.maximo();
                //aPerM = new APermanenteVO(cod,desc,codOEsp,0,respon,max,numdependencia);
                //supportFacade.spManM(tipo, aPerM);

                lista = supportFacade.getListById(codOEsp);
                form1.setListaAPermanente(lista);
                cadenaSalida.append("<table id='tabla1' width='99%' align='right' class='userTable'>");
                cadenaSalida.append("<tr class='even' align='center'>");
                cadenaSalida.append("<th class='textoTR'>#</th>");
                cadenaSalida.append("<th class='textoTR'>Actividad Estrat&eacute;gica</th> ");
                cadenaSalida.append("<th class='textoTR'>Responsable </th> ");
                cadenaSalida.append("<th class='textoTR'>Editar</th>");
                cadenaSalida.append("<th class='textoTR'>Eliminar</th> ");
                cadenaSalida.append("<th class='textoTR'>Meta</th> ");
                cadenaSalida.append("</tr>");
                int i=1;
                Iterator it = lista.iterator();
                while (it.hasNext()) {
                    aPer = (APermanenteVO) it.next();

                    cadenaSalida.append("<tr align='center'> ");
                      cadenaSalida.append("<td width='10%' align='center'>" + aPer.getNUM_IDOBJ() + "." +aPer.getNUM_IDOBJESP()+ "."+aPer.getNUM_IDACTPER()+ "." +"</td>");
                    cadenaSalida.append("<td style='width:1500px;text-align: left' align='center'>" + aPer.getTX_DESCACTPER() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + aPer.getTX_DESCRESP() + "</td>");




                    cadenaSalida.append("<td width='10%' align='center'>");
                    cadenaSalida.append("<img style='cursor:pointer' title='Editar' alt='Editar' border=0  src='images/b_edit.png' onclick=\"editar('" + aPer.getNUM_IDACTPER() + "','" + aPer.getTX_DESCACTPER()+ "','" + aPer.getNUM_CODACTPER_PK() + "','" + aPer.getNUM_CODDEPEN_PK() + "');posicioninicial();\" >");

                    cadenaSalida.append("</td>");
                    cadenaSalida.append("<td width='10%' align='center'> ");
                    cadenaSalida.append("<img style='cursor:pointer' title='Eliminar' alt='Eliminar' border=0  src='images/b_drop.png' onclick=\"eliminar('" + aPer.getNUM_CODACTPER_PK() + "');\" >");
                    cadenaSalida.append("</td>");
                    cadenaSalida.append("<td width='20%' align='center'> ");


                        cadenaSalida.append("<img style='cursor:pointer' title='Actividad Permanente' alt='APermanente' border=0  src='images/file_preview.png' onclick=\"meta('" + aPer.getNUM_CODACTPER_PK()  + "','"+ aPer.getNUM_IDACTPER()+ "','"+ aPer.getTX_DESCACTPER() + "','" + aPer.getTX_DESCRESP() + "');\">");

                    cadenaSalida.append("</td>");

                    cadenaSalida.append("</tr>");
                }
            } catch (Exception e) {
                    cadenaSalida.append("error : "+e.toString());
            }
            out.print(cadenaSalida);
%>